import 'package:flutter/material.dart';
import '../search.dart';
import '../form.dart';

class CategoryPage extends StatefulWidget {
  const CategoryPage({super.key});

  @override
  State<CategoryPage> createState() => _CategoryPageState();
}

//路由跳转
class _CategoryPageState extends State<CategoryPage> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          //按钮
          ElevatedButton(
            onPressed: (){
              Navigator.of(context).push(
                //跳转路由
                MaterialPageRoute(builder: (BuildContext context){
                  return const SearchPage();
                })
              );
            },
            child: const Text("基本路由跳转"),
          ),

          const SizedBox(height: 20,),
          ElevatedButton(
            onPressed: (){
              Navigator.pushNamed(context, "/search");
            },
            child: const Text("命名路由跳转"),
          ),

          const SizedBox(height: 20,),

          //跳转表单页面并传参
          ElevatedButton(
            onPressed: (){
              Navigator.of(context).push(
                //跳转路由
                MaterialPageRoute(builder: (BuildContext context){
                  return const FormPage(title: "我是传递的标题", aid: 3,);
                })
              );
            },
            child: const Text("基本表单传值"),
          ),

          const SizedBox(height: 20,),

          ElevatedButton(
            onPressed: (){
              Navigator.pushNamed(context, "/shop", arguments: {
                "title" : "命名路由传值",
                "aid" : 21,
              });
            },
            child: const Text("命名路由传值"),
          ),


          const SizedBox(height: 20,),




        ],
      ),
    );
  }
}







